//
//  GFkfViewController.m
//  day1
//
//  Created by 于跃隆 on 2020/4/7.
//  Copyright © 2020 于跃隆. All rights reserved.
//

#import "GFkfViewController.h"

@interface GFkfViewController ()

@end

@implementation GFkfViewController

-(void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    
    self.navigationController.navigationBar.hidden = YES;
    
}

-(void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
    self.navigationController.navigationBar.hidden = NO;
}
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self setNavContorlFrame];
    self.navigationController.navigationBar.hidden = NO;
}
-(void)setNavContorlFrame{
    //设置导航条颜色
        UIView *Jbview = [[UIView alloc] init];
        Jbview.userInteractionEnabled = YES;
    //    Jbview.frame = CGRectMake(0,KSCHEIGHT(-37),kSCRATIO(self.view.frame.size.width),KSCHEIGHT(75));

        CAGradientLayer *gl = [CAGradientLayer layer];
        gl.frame = CGRectMake(0,KSCHEIGHT(0),kSCRATIO(self.view.frame.size.width),KSCHEIGHT(82));
        gl.startPoint = CGPointMake(0, 0);
        gl.endPoint = CGPointMake(1, 1);
        gl.colors = @[(__bridge id)[UIColor colorWithRed:247/255.0 green:65/255.0 blue:91/255.0 alpha:1.0].CGColor,(__bridge id)[UIColor colorWithRed:251/255.0 green:171/255.0 blue:102/255.0 alpha:1.0].CGColor];
        gl.locations = @[@(0.0),@(1.0)];
        [Jbview.layer addSublayer:gl];
        
        [self.navigationController.navigationBar addSubview:Jbview];
        
        //返回button
        UIButton *backBtn = [[UIButton alloc] init];
        [backBtn setBackgroundImage:[UIImage imageNamed:@"backButton"] forState:UIControlStateNormal];
        [backBtn addTarget:self action:@selector(BackClick) forControlEvents:UIControlEventTouchUpInside];
        [Jbview addSubview:backBtn];
        
        //标题文字
        UILabel *navtitle = [[UILabel alloc] init];
        navtitle.text = @"官方客服";
        navtitle.textColor = [UIColor whiteColor];
        navtitle.font = kFONT(18);
        [Jbview addSubview:navtitle];
        
        [Jbview mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(KSCHEIGHT(-37));
            make.width.mas_equalTo(kSCRATIO(self.view.frame.size.width));
            make.height.mas_equalTo(KSCHEIGHT(82));
        }];
        [backBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(Jbview.mas_left).mas_equalTo(kSCRATIO(20));
            make.bottom.mas_equalTo(Jbview.bottom).mas_equalTo(KSCHEIGHT(-15));
            make.width.mas_equalTo(kSCRATIO(10));
            make.height.mas_equalTo(KSCHEIGHT(18));
        }];
        [navtitle mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.mas_equalTo(Jbview);
            make.bottom.mas_equalTo(Jbview.bottom).mas_equalTo(KSCHEIGHT(-12));
            
        }];
}


- (void)viewDidLoad {
    [super viewDidLoad];
    
    //245 246 251
    self.view.backgroundColor = [UIColor colorWithRed:245/255.0 green:246/255.0 blue:251/255.0 alpha:1.0];
    
    
    
    [self setContViewFrame];
    
}
-(void)setContViewFrame{
    UIImageView *TouimageV = [[UIImageView alloc] init];
    TouimageV.image = [UIImage imageNamed:@"customer_service01"];
    [self.view addSubview:TouimageV];
    
    [TouimageV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.view);
        make.top.mas_equalTo(self.view.mas_top).mas_equalTo(KSCHEIGHT(40));
        make.width.height.mas_equalTo(kSCRATIO(215));
    }];
    
    UILabel *kefuLabel = [[UILabel alloc] init];
    kefuLabel.frame = CGRectMake(124,358,127,40.5);
    kefuLabel.numberOfLines = 0;
    kefuLabel.userInteractionEnabled = YES;
    [kefuLabel addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(copyNumber)]];
    [self.view addSubview:kefuLabel];

    NSMutableAttributedString *kefustring = [[NSMutableAttributedString alloc] initWithString:@"24小时服务电话400-800-8888" attributes:@{NSFontAttributeName: [UIFont fontWithName:@"PingFangSC-Semibold" size: kSCRATIO(18)],NSForegroundColorAttributeName: [UIColor colorWithRed:248/255.0 green:80/255.0 blue:92/255.0 alpha:1.0]}];

//    [kefustring addAttributes:@{NSFontAttributeName: [UIFont fontWithName:@"PingFangSC-Regular" size: kSCRATIO(18)]} range:NSMakeRange(0, 22)];

//    [kefustring addAttributes:@{NSFontAttributeName: [UIFont fontWithName:@"PingFangSC-Regular" size: kSCRATIO(18)]} range:NSMakeRange(0, 22)];

    kefuLabel.attributedText = kefustring;

    [kefuLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.view);
        make.top.mas_equalTo(TouimageV.mas_bottom).mas_equalTo(KSCHEIGHT(30));
        make.width.mas_equalTo(kSCRATIO(130));

    }];

    UILabel *Lingtlabel = [[UILabel alloc] init];
    Lingtlabel.frame = CGRectMake(102.5,420,170,12);
    Lingtlabel.numberOfLines = 0;
    [self.view addSubview:Lingtlabel];

    NSMutableAttributedString *lingtstring = [[NSMutableAttributedString alloc] initWithString:@"用心倾听您的声音 竭诚为您服务" attributes:@{NSFontAttributeName: [UIFont fontWithName:@"PingFangSC-Regular" size: kSCRATIO(12)],NSForegroundColorAttributeName: [UIColor colorWithRed:102/255.0 green:102/255.0 blue:102/255.0 alpha:1.0]}];

    Lingtlabel.attributedText = lingtstring;

    [Lingtlabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.view);
        make.top.mas_equalTo(kefuLabel.mas_bottom).mas_equalTo(KSCHEIGHT(20));

    }];
    
}
-(void)copyNumber{
    UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
    pasteboard.string = @"400-800-8888";
    [HWProgressHUD showMessage:@"电话已复制"];
}

-(void)BackClick{
    [self.navigationController popViewControllerAnimated:NO];
}





@end
